<template>
  <zm-view ref="view">
    <view class="flex flex-col items-center pt-60 font-30 font-bold">
      <image class="logo-image" src="/static/logo.png" mode="scaleToFill" />
      <text class="mt-20">福州爱来网络科技有限责任公司</text>
      <text class="mt-15">{{ baseInfo.priSubject || manifest.name }}</text>
    </view>
    <zm-cell-group
      border-radius="16rpx"
      title-size="30rpx"
      content-size="30rpx"
      content-color="#999999"
      right-icon-size="32rpx"
      right-icon-color="#cccccc"
      right-icon-weight="bold"
      custom-class="mt-20"
    >
      <zm-cell title="当前版本" :content="`V${version}`" height="96rpx" :clickable="false" padding="0 20rpx" @click="handleClick"></zm-cell>
      <zm-cell title="隐私政策" height="96rpx" is-link padding="0 20rpx" @click="handleToUserPyAt"></zm-cell>
      <zm-cell :title="`${baseInfo.priSubject || manifest.name}用户协议`" height="96rpx" is-link padding="0 20rpx" @click="handleToUserAt"></zm-cell>
    </zm-cell-group>
  </zm-view>
</template>

<script>
import page from "@/mixins/page"
import hook from "@/mixins/hook"
import manifest from "@/manifest.json"
import { mapMutations, mapGetters } from "vuex"
export default {
  mixins: [page, hook],
  data() {
    return {
      manifest,
      version: "",
      count: 0,
      timer: null
    }
  },
  computed: {
    ...mapGetters(["developMode", "baseInfo"])
  },
  onLoad() {
    this.getVersion()
  },
  methods: {
    ...mapMutations(["SET_DEVELOP_MODE"]),
    handleClick() {
      if (this.count >= 5) return
      clearTimeout(this.timer)
      this.count++
      this.timer = setTimeout(() => {
        this.count = 0
      }, 500)
      if (this.count == 5) {
        this.SET_DEVELOP_MODE(!this.developMode)
        if (this.developMode) {
          this.$toast("开启开发者模式成功")
        } else {
          this.$toast("关闭开发者模式成功")
        }
      }
    },
    // 跳转用户协议
    handleToUserAt() {
      this.toView({
        url: "pages/person/user-agreement/user-agreement",
        params: { type: "userAt", title: `${this.baseInfo.priSubject || this.manifest.name}用户协议` }
      })
    },
    // 跳转用户隐私协议
    handleToUserPyAt() {
      uni.$toView({
        url: "pages/person/user-agreement/user-agreement",
        params: { type: "userPyAt", title: `${this.baseInfo.priSubject || this.manifest.name}隐私协议` }
      })
    },
    // 获取版本号
    async getVersion() {
      const res = await uni.getSystemInfoSync()
      this.version = res.appVersion
    }
  }
}
</script>

<style lang="scss" scoped>
.logo-image {
  width: 154rpx;
  height: 154rpx;
  border-radius: 30rpx;
}
</style>
